home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / libwww2 / HTUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  6.5 KB  |  272 lines

  1. /*                                                    Utitlity macros for the W3 code library
  2.                                   MACROS FOR GENERAL USE
  3.                                              
  4.    Generates: HTUtils.h
  5.    
  6.    See also: the system dependent file "tcp.h"
  7.    
  8.  */
  9.  
  10. #ifndef DEBUG
  11. #define DEBUG   /* Noone ever turns this off as trace is too important */
  12. #endif          /* Keeep option for really small memory applications tho */
  13.                 
  14. #ifndef HTUTILS_H
  15. #define HTUTILS_H
  16.  
  17. #ifdef SHORT_NAMES
  18. #define WWW_TraceFlag HTTrFlag
  19. #endif
  20.  
  21. #ifdef _AMIGA
  22.  #include <exec/types.h>
  23.  #ifndef BOOLEAN_DEFINED
  24.   typedef BOOL BOOLEAN;
  25.   #define BOOLEAN_DEFINED
  26.  #endif
  27.  #ifndef TRUE
  28.   #define TRUE    (BOOLEAN)1
  29.   #define FALSE   (BOOLEAN)0
  30.  #endif /* TRUE */
  31. #endif /* _AMIGA */
  32.  
  33. /*
  34.  
  35. Debug message control.
  36.  
  37.  */
  38. #ifndef STDIO_H
  39. #include <stdio.h>
  40. #define STDIO_H
  41. #endif
  42.  
  43. #ifdef DEBUG
  44. #define TRACE (WWW_TraceFlag)
  45. #define PROGRESS(str) printf(str)
  46.         extern int WWW_TraceFlag;
  47. #else
  48. #define TRACE 0
  49. #define PROGRESS(str) /* nothing for now */
  50. #endif
  51.  
  52. #define CTRACE if(TRACE)fprintf
  53. #define tfp stderr
  54.  
  55.  
  56. /*
  57.  
  58. Standard C library for malloc() etc
  59.  
  60.  */
  61. #ifdef vax
  62. #ifdef unix
  63. #define ultrix  /* Assume vax+unix=ultrix */
  64. #endif
  65. #endif
  66.  
  67. #ifndef VMS
  68. #ifndef ultrix
  69. #ifdef NeXT
  70. #include <libc.h>       /* NeXT */
  71. #endif
  72. #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
  73. #include <stdlib.h>     /* ANSI */
  74. #endif
  75. #else /* ultrix */
  76. #include <malloc.h>
  77. #include <memory.h>
  78. #include <stdio.h>
  79. #endif
  80.  
  81. #else   /* VMS */
  82. #include <stdio.h>
  83. #include <ctype.h>
  84. #endif
  85.  
  86. #ifdef __sgi
  87. #include <malloc.h>
  88. #endif
  89.  
  90.  
  91. /*
  92.  
  93. Macros for declarations
  94.  
  95.  */
  96. #define PUBLIC                  /* Accessible outside this module     */
  97. #define PRIVATE static          /* Accessible only within this module */
  98.  
  99. #ifdef __STDC__
  100. #if 0
  101. #define CONST const             /* "const" only exists in STDC */
  102. #endif
  103. #define CONST
  104. #define NOPARAMS (void)
  105. #define PARAMS(parameter_list) parameter_list
  106. #define NOARGS (void)
  107. #define ARGS1(t,a) \
  108.                 (t a)
  109. #define ARGS2(t,a,u,b) \
  110.                 (t a, u b)
  111. #define ARGS3(t,a,u,b,v,c) \
  112.                 (t a, u b, v c)
  113. #define ARGS4(t,a,u,b,v,c,w,d) \
  114.                 (t a, u b, v c, w d)
  115. #define ARGS5(t,a,u,b,v,c,w,d,x,e) \
  116.                 (t a, u b, v c, w d, x e)
  117. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
  118.                 (t a, u b, v c, w d, x e, y f)
  119. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
  120.                 (t a, u b, v c, w d, x e, y f, z g)
  121. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
  122.                 (t a, u b, v c, w d, x e, y f, z g, s h)
  123. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
  124.                 (t a, u b, v c, w d, x e, y f, z g, s h, r i)
  125. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
  126.                 (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
  127.  
  128. #else  /* not ANSI */
  129.  
  130. #define CONST
  131. #define NOPARAMS ()
  132. #define PARAMS(parameter_list) ()
  133. #define NOARGS ()
  134. #define ARGS1(t,a) (a) \
  135.                 t a;
  136. #define ARGS2(t,a,u,b) (a,b) \
  137.                 t a; u b;
  138. #define ARGS3(t,a,u,b,v,c) (a,b,c) \
  139.                 t a; u b; v c;
  140. #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
  141.                 t a; u b; v c; w d;
  142. #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
  143.                 t a; u b; v c; w d; x e;
  144. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
  145.                 t a; u b; v c; w d; x e; y f;
  146. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
  147.                 t a; u b; v c; w d; x e; y f; z g;
  148. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
  149.                 t a; u b; v c; w d; x e; y f; z g; s h;
  150. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
  151.                 t a; u b; v c; w d; x e; y f; z g; s h; r i;
  152. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
  153.                 t a; u b; v c; w d; x e; y f; z g; s h; r i; q j;
  154.                 
  155.         
  156. #endif /* __STDC__ (ANSI) */
  157.  
  158. #ifndef NULL
  159. #define NULL ((void *)0)
  160. #endif
  161.  
  162. /*
  163.  
  164. Booleans
  165.  
  166.  */
  167. /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
  168. /* #define GOOD(status) ((status)38;1)   VMS style status: test bit 0         */
  169. /* #define BAD(status)  (!GOOD(status))  Bit 0 set if OK, otherwise clear   */
  170.  
  171. #ifndef BOOLEAN_DEFINED
  172.         typedef char    BOOLEAN;                /* Logical value */
  173. #ifndef TRUE
  174. #define TRUE    (BOOLEAN)1
  175. #define FALSE   (BOOLEAN)0
  176. #endif
  177. #define BOOLEAN_DEFINED
  178. #endif
  179.  
  180. #ifndef BOOL
  181. #define BOOL BOOLEAN
  182. #endif
  183. #ifndef YES
  184. #define YES (BOOLEAN)1
  185. #define NO (BOOLEAN)0
  186. #endif
  187.  
  188. #ifndef min
  189. #define min(a,b) ((a) <= (b) ? (a) : (b))
  190. #define max(a,b) ((a) >= (b) ? (a) : (b))
  191. #endif
  192.  
  193. #define TCP_PORT 80     /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
  194.  
  195. /*      Inline Function WHITE: Is character c white space? */
  196. /*      For speed, include all control characters */
  197.  
  198. #define WHITE(c) (((unsigned char)(c)) <= 32)
  199.  
  200.  
  201. /*
  202.  
  203. Sucess (>=0) and failure (<0) codes
  204.  
  205.  */
  206.  
  207. #define HT_REDIRECTING 29998
  208. #define HT_LOADED 29999                 /* Instead of a socket */
  209. #define HT_INTERRUPTED -29998
  210. #define HT_NOT_LOADED -29999
  211. #define HT_OK           0               /* Generic success*/
  212.  
  213. #define HT_NO_ACCESS    -10             /* Access not available */
  214. #define HT_FORBIDDEN    -11             /* Access forbidden */
  215. #define HT_INTERNAL     -12             /* Weird -- should never happen. */
  216. #define HT_BAD_EOF      -12             /* Premature EOF */
  217.  
  218. #include "HTString.h"   /* String utilities */
  219.  
  220. #ifdef __STDC__
  221. #include <stdarg.h>
  222. #else
  223. #include <varargs.h>
  224. #endif
  225.  
  226. /*
  227.  
  228. Out Of Memory checking for malloc() return:
  229.  
  230.  */
  231. #ifndef __FILE__
  232. #define __FILE__ ""
  233. #define __LINE__ ""
  234. #endif
  235.  
  236. #define outofmem(file, func) \
  237.  { fprintf(stderr, "%s %s: out of memory.\nProgram aborted.\n", file, func); \
  238.   exit(1);}
  239.  
  240.  
  241. /*
  242.  
  243. Upper- and Lowercase macros
  244.  
  245.    The problem here is that toupper(x) is not defined officially unless isupper(x) is.
  246.    These macros are CERTAINLY needed on #if defined(pyr) || define(mips) or BDSI
  247.    platforms. For safefy, we make them mandatory.
  248.    
  249.  */
  250. #include <ctype.h>
  251.  
  252. #ifndef TOLOWER
  253.   /* Pyramid and Mips can't uppercase non-alpha */
  254. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  255. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  256. #endif /* ndef TOLOWER */
  257.  
  258. #define CR '\015'    /* Must be converted to ^M for transmission */
  259. #define LF '\012'    /* Must be converted to ^J for transmission */
  260.  
  261. #if defined(SYSV) || defined(SVR4) || defined(__svr4__) || defined(VMS)
  262. #define bcopy(source, dest, count) memcpy(dest, source, count)
  263. #define bzero(b, len) memset(b, 0, len)
  264. #endif
  265.  
  266.  
  267. #endif /* HTUTILS_H */
  268.  
  269. /*
  270.  
  271.    end of utilities  */
  272.